<template>
  <div class="resume-detail-education info-group">
    <div class="info-group-title">
      教育经历<span
        class="info-group-action"
        type="primary"
        @click="$emit('edit')"
        ><SvgIcon name="xinjian2" />添加教育经历</span
      >
    </div>
    <div class="info-group-content">
      <div class="education-row" v-for="(item, index) in data" :key="index">
        <div class="education-item">
          {{ item.startDate }}-{{ item.endDate }}
        </div>
        <div class="education-item">毕业院校：{{ item.schoolName }}</div>
        <div class="education-item">专业名称：{{ item.majorName }}</div>
        <div class="education-item">文化程度：{{ item.degreeName }}</div>
        <div class="education-info-action">
          <span type="primary" @click="handleRemove(item.id)"
            ><SvgIcon name="shanchu" />删除</span
          >
          <span type="primary" @click="$emit('edit', item)"
            ><SvgIcon name="xiugai1" />编辑</span
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { deleteEducationExperience } from 'services/student/resume'
export default {
  name: 'ResumeDetailEducation',
  props: {
    data: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    async handleRemove(id) {
      try {
        await this.$confirm(
          this.$t('tip.removeTip'),
          this.$t('tip.systemTip'),
          {
            type: 'warning'
          }
        )
        const ids = [id]
        await deleteEducationExperience(ids)
        this.$bus.$emit('resume-update')
      } catch {}
    }
  }
}
</script>

<style lang="scss">
@import 'styles/common.scss';
.resume-detail-education {
  .education-row {
    margin-left: -10px;
    padding-left: 10px;
    padding-right: 100px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    position: relative;
    .education-item {
      flex: 1;
    }
    .education-edit {
      color: $colorPrimary;
      cursor: pointer;
      .svg-icon {
        margin-right: 10px;
      }
    }
    .education-info-action {
      display: none;
      position: absolute;
      top: 20px;
      right: 0.35rem;
      margin: auto;
      color: $colorPrimary;
      cursor: pointer;
      .svg-icon {
        margin-left: 20px;
        margin-right: 10px;
      }
    }
    &:hover {
      background-color: $colorBG2;
      .education-info-action {
        display: block;
      }
    }
  }
}
</style>
